/**
 * Created by xjweng on 2017/1/15.
 */
var phoneDetail = angular.module('phoneDetail',['ngRoute','core.phone']);
phoneDetail.directive("phoneDetail",function () {
    return {
        scope:true,
/*        template:'TBD: Detail view for <span>{{phoneId}}</span>',*/
        templateUrl: 'phone-detail/phone-detail.template.html',
        controller: "detailController"
        /*['Phone',function($scope,$routeParams,$http,Phone) {
            /!*$scope.phoneId = $routeParams.phoneId;*!/

            /!*$http方法1*!/
            /!*$http.get('phones/' + $routeParams.phoneId + '.json').
            then(function (response) {
                /!*$scope.phone = response.data;
                 console.log(response);*!/
                $scope.phone = response.data;
                $scope.setImage($scope.phone.images[0]);
            })*!/

        }]*/
    }
})
    .controller("detailController",["$scope","$routeParams","Phone",
        function ($scope,$routeParams,Phone) {
            $scope.setImage = function (imgUrl) {
                $scope.mainImageUrl = imgUrl;
            };
            console.log(Phone);
            $scope.phone = Phone.get({phoneId: $routeParams.phoneId},function () {
                $scope.setImage($scope.phone.images[0]);
            })
    }])